package com.library.service.impl;



import com.library.common.core.domain.BaseEntity;
import com.library.common.core.text.Convert;
import com.library.domain.MbGift;
import com.library.mapper.MbGiftMapper;
import com.library.service.IMbGiftService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 签到礼品 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class MbGiftServiceImpl implements IMbGiftService {
    @Resource
    private MbGiftMapper mbGiftMapper;

    /**
     * 查询签到礼品信息
     *
     * @param id 签到礼品ID
     * @return 签到礼品信息
     */
    @Override
    public MbGift selectMbGiftById(Integer id) {
        return mbGiftMapper.selectMbGiftById(id);
    }

    /**
     * 查询签到礼品列表
     *
     * @param mbGift 签到礼品信息
     * @return 签到礼品集合
     */
    @Override
    public List<MbGift> selectMbGiftList(MbGift mbGift) {
        return mbGiftMapper.selectMbGiftList(mbGift);
    }

    /**
     * 新增签到礼品
     *
     * @param mbGift 签到礼品信息
     * @return 结果
     */
    @Override
    public int insertMbGift(MbGift mbGift) {
        return mbGiftMapper.insertMbGift(mbGift);
    }

    /**
     * 修改签到礼品
     *
     * @param mbGift 签到礼品信息
     * @return 结果
     */
    @Override
    public int updateMbGift(MbGift mbGift) {
        return mbGiftMapper.updateMbGift(mbGift);
    }

    /**
     * 删除签到礼品对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMbGiftByIds(String ids) {
        String[] strings = Convert.toStrArray(ids);
        for (String id : strings) {
            MbGift mbGift = mbGiftMapper.selectMbGiftById(Integer.valueOf(id));
            if (null == mbGift)
                continue;
            mbGift.setIsDelete(BaseEntity.DELETE);
            mbGiftMapper.updateMbGift(mbGift);
        }
        return BaseEntity.DELETE;
    }

}
